﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// Default implementation for QueryResult has the host, execution time and the
    /// query result.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class QueryResultImpl<T> : ExecutionResult<T>, QueryResult<T>
    {
        public QueryResultImpl(T value, long execTime, CassandraHost cassandraHost, Query<T> query) : base(value, execTime, cassandraHost)
        {
            Query = query;
            base.Get = value;
        }
        public QueryResultImpl(ExecutionResult<T> res, Query<T> query) : base(res.Get, res.ExecutionTimeNano, res.HostUsed)
        {
            Query = query;
        }
        protected Query<T> Query
        {
            get;
            set;
        }
        public Query<T> GetQuery()
        {
            return Query;
        }
        public new T Get()
        {
            return base.Get;
        }
        public override string ToString()
        {
            return FormatMessage("Result", Query.ToString());
        }
    }
}
